<?php
/*
 *  Maniter: A webbased business managment tool.
 *  Copyright (C) 2007  Dimitri Michaux <dimitri.michaux@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * settings.php, Maniter
 * 
 * Save and display the setting for Maniter
 *
 * @author Dimitri Michaux
 * @version 0.1
 * @package maniter_core
 */

require_once("lib-common.php");

$ownerInfo = PurchaseList::getOwnerInfo();

if( isset($_POST['save']) ) {
	//save owner information
	if( isset($_POST['company']) )
		$ownerInfo->setCompany( $_POST['company'] );
	
	if( isset($_POST['street']) )
		$ownerInfo->setStreet( $_POST['street'] );
	
	if( isset($_POST['city']) )
		$ownerInfo->setCity( $_POST['city'] );
	
	if( isset($_POST['phone']) )
		$ownerInfo->setPhone( $_POST['phone'] );
	 
	if( isset($_POST['fax']) )
		$ownerInfo->setFax( $_POST['fax'] );
	
	if( isset($_POST['vatnr']) )
		$ownerInfo->setVatNr( $_POST['vatnr'] );
		
	if( isset($_POST['bankaccount']) )
		$ownerInfo->setBankAccount( $_POST['bankaccount'] );
		
	if( isset($_POST['website']) )
		$ownerInfo->setWebsite	( $_POST['website'] );
		
	if( isset($_POST['email']) )
		$ownerInfo->setEmail( $_POST['email'] );
		
	PurchaseList::saveOwnerInfo( $ownerInfo );
	
	if( isset($_POST['ordertext']) )
		DB::get()->update('var_blob', array('name'=>'ordertext','value'=>$_POST['ordertext']), "name='ordertext'");
	
	if( isset($_POST['offerheadertext']) )
		DB::get()->update('var_blob', array('name'=>'offerheadertext','value'=>$_POST['offerheadertext']), "name='offerheadertext'");
		
	if( isset($_POST['offerfootertext']) )
		DB::get()->update('var_blob', array('name'=>'offerfootertext','value'=>$_POST['offerfootertext']), "name='offerfootertext'");
}

$tpl->setTitle( 'Instellingen' );
$tpl->settingsPage( $ownerInfo );
$tpl->output();
?>